<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>循环语句</title>
  <script type="text/javascript">
/* 
练习：年利率为5%，从1000块到5000块要几年？
*/
var money=1000;
/* var num=0;
while(true){
  money+=0.05*money;
  num++;
  if(money>=5000){
    break;
  }
} 
console.log(num);//33*/
var year=0;
do{
   money+=0.05*money;
   year++;
   if(money>=5000){
    break;
   }
  }while(true);
  console.log(year);//33

  </script>
</head>
<body>
  
</body>
</html>